package com.ruoyi.oa.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.oa.domain.bo.OaHumanSelectMonthBo;
import com.ruoyi.oa.domain.vo.OaHumanClockCountVo;
import com.ruoyi.oa.domain.bo.OaHumanClockCountBo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.oa.domain.OaHumanClockTotal;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 考勤记录Service接口
 *
 * @author ruoyi
 * @date 2023-07-19
 */
public interface IOaHumanClockCountService {

    /**
     * 查询考勤记录
     */
    OaHumanClockCountVo queryById(String id);

    /**
     * 查询考勤记录列表
     */
    TableDataInfo<OaHumanClockCountVo> queryPageList(OaHumanClockCountBo bo, PageQuery pageQuery);

    /**
     * 查询考勤记录列表
     */
    List<OaHumanClockCountVo> queryList(OaHumanClockCountBo bo);

    /**
     * 新增考勤记录
     */
    Boolean insertByBo(OaHumanClockCountBo bo);

    /**
     * 修改考勤记录
     */
    Boolean updateByBo(OaHumanClockCountBo bo);

    /**
     * 校验并批量删除考勤记录信息
     */
    Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);

    /**
     * 根据用户查询当天打卡信息
     * @param userId
     * @return
     */
    public OaHumanClockCountVo selectTodayVoByUserId(String userId);

    /**
     * 获取用户昨天打卡信息
     * @param userId
     * @return
     */
    OaHumanClockCountVo selectLastVoByUserId( String userId);


    /**
     * 根据用户id和月份，查询
     * @param userId
     * @param month
     * @return
     */
    int getReplaceCountByIdAndMonth(String userId,String month);
    /**
     * 根据规则Id查询当天规则
     * @param ruleId
     * @return
     */
    public List<OaHumanClockCountVo> getTodayCountListByRuleId(String ruleId,String dateString);

    /**
     * 查询昨天打卡信息
     * @param
     * @return
     */
    public List<OaHumanClockCountVo> getLastCountList();

    /**
     * 获取今天所有打卡信息
     * @return
     */
    List<OaHumanClockCountVo> getTodayCountList();


     void updateCountRules(String ruleId);

    TableDataInfo<OaHumanClockTotal> selectSumInfo(OaHumanClockCountBo bo, PageQuery pageQuery);

    public TableDataInfo<OaHumanClockTotal> selectSumInfoForApp(OaHumanClockCountBo bo, PageQuery pageQuery);
    List<OaHumanClockTotal> exportSumInfo(OaHumanClockCountBo bo);

    public TableDataInfo<Object> getSumDetail(OaHumanSelectMonthBo bo, PageQuery pageQuery);

    OaHumanClockCountVo selectLastByUserId(String userId,String dateString);

    OaHumanClockTotal selectSumInfoByMonth(String month);

    List<OaHumanClockCountVo> selectCountByDate(String dateString);

    OaHumanClockTotal selectSumInfoByDate(String date);

    /**
     * 获取当月用户打卡信息
     * @param month
     * @param userId
     * @return
     */
    OaHumanClockTotal selectSumInfoByMonthAndUserId(String month,String userId);
    int cleanEndTime(String id);

    int cleanStartTime(String id);

    /**
     * 根据条件查询日报
     * @param bo
     * @return
     */
    TableDataInfo<OaHumanClockCountVo> queryPerDaySum(OaHumanClockCountBo bo, PageQuery pageQuery);

    Map<String, Object> SelectNormalUserByMonth(String month);

    public Map<String, Object> SelectNormalUserByDate(String date);

    /**
     * 通过月份以及用户id获取用户当月打卡条数
     * @param userId
     * @param dateString
     * @return
     */
    Integer getUserClockCountByMonth(String userId,String dateString);

    /**
     * 获取某人本月外勤次数
     * @param month
     * @param userId
     * @return
     */
    Integer getOutSideCount(String month, String userId);

    /**
     * 获取某人某月的请假次数
     * @param month
     * @param userId
     * @return
     */
    Integer getLeaveCount(String month,String userId);


    public List<OaHumanClockCountVo> getLeaveData(String month, String userId);
}
